<template>
	<view v-if="item">
	<view class="name">
		{{item.name}}
		你到这里有{{dis}}km
	</view>
	<uni-search-bar @confirm="searchCityBus" v-model="searchKey"></uni-search-bar>
	<button type="default" @tap="goto('钟楼')">我到哪</button>
	<button @click="toggleFavorite">收藏</button>
	</view>
</template>

<script setup>
	import { ref, computed } from "vue";
	import { onLoad } from '@dcloudio/uni-app';
	import { userStore } from "../../store/userStore";
	import { CONFIG } from "@/utils/config.js";
	import { getMapDistance } from "../../utils/tools";
	let store = userStore();
	let item = ref({});
	let dis = ref({});
	onLoad((data) => {
		console.log(data.item);
		const json = decodeURI(data.item);
		console.log(json);
		item.value = JSON.parse(json);
		console.log(item.value);
		dis.value = getMapDistance(store.currentPos.latitude, store.currentPos.longitude, item.value.latitude, item.value.longitude);
		getItemById();
	});

	const location = ref({
		latitude: 34.341568,  // 西安市默认纬度
		longitude: 108.940174 // 西安市默认经度
	});

function goto(placeName){
	// 假设钟楼的经纬度
	const zhonglou = {
		latitude: 34.341568,
		longitude: 108.940174
	};
	uni.navigateTo({
		url: `/pages/mywebView/mywebView?lat=${zhonglou.latitude}&lon=${zhonglou.longitude}&name=${placeName}&type=2`
	});
}

const hasFav = ref(true);
</script>

<style></style>

	
	
	



